package org.reos.ReParser;

import java.util.ArrayList;

/**
 * Created with IntelliJ IDEA.
 * User: cfrn76
 * Date: 09.12.13
 * Time: 18:33
 * To change this template use File | Settings | File Templates.
 */
public class ReParser {
    ArrayList<ISection> configData;
    public ArrayList<ParserDataCore> getParserData() {
        if (configData == null) {
            return null;
        }
        ArrayList<ParserDataCore> returnData = new ArrayList<ParserDataCore>();
        for (ISection section : configData) {
            ParserDataCore tmp = section.getParserDataFromSection();
            if (tmp != null) {
                returnData.add(tmp);
            }
        }
        return returnData;
    }

    public boolean parseConfigFile(String fileName) {
        configData = new RTGenConfigReader().populateConfigFromFile(fileName);
        if (configData != null) {
            if (ConfigDataValidator.validateConfigData(configData) == true) {
                return true;
            }
        }
        return false;
    }

    public enum ParserDataType {
        SYSTEM("SYSTEM"), ISR("ISR"), MESSAGE("MESSAGE"), EVENT("EVENT"), TASK("TASK");
        private String type;
        private ParserDataType(String type) {
            this.type = type;
        }
        @Override
        public String toString() {
            return this.type;
        }
    }
}
